<template>
  <div style="background: #e8e8e8;">
    <div class="page_content">
      <div>
        <img class="title_img" src="@/assets/title (project).png" alt="">
      </div>

      <div class="nav">
        <span :class="{ 'bold-black': projectId === '0' }" @click="selectProject('0')">全部</span>/
        <span :class="{ 'bold-black': projectId === '1' }" @click="selectProject('1')">建筑设计</span>/
        <span :class="{ 'bold-black': projectId === '2' }" @click="selectProject('2')">室内设计</span>/
        <span :class="{ 'bold-black': projectId === '3' }" @click="selectProject('3')">文创街区</span>/
      </div>
      <div class="line"></div>
      <ul class="institute_list">
        <li class="product-item" v-for="item in 8">
          <router-link to="/projectCount">
            <img src="@/assets/project.jpg" alt="">
            <div class="title">杭州湾奥特莱斯</div>
            <div class="title2">建筑设计, 浙江·宁波</div>
          </router-link>

        </li>
      </ul>
    </div>
  </div>
</template>

<script setup>
import { ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';

const route = useRoute();
const router = useRouter(); // 获取 router 实例
// console.log("route.query.id._value", route.query.id);
const projectId = ref(route.query.id) // 获取 id 参数
console.log("projectId", projectId);
watch(
  () => route.query.id, // 监听路由查询参数中的 id
  (newId) => {
    projectId.value = newId; // 更新 projectId
  }
);

const selectProject = (id) => {
  projectId.value = id;
  router.push({ path: `/project`, query: { id } }); // 跳转到 /project?id=id
};

</script>

<style lang="scss" scoped>
.page_content {
  .title_img {
    margin-top: 40px;
    margin-bottom: 10px;
  }

  .nav {
    font-size: 0.9rem;
    color: #696969;
    margin-bottom: 20px;

    .bold-black {
      font-weight: bold;
      color: black;
    }

    span {
      margin-right: 0.6rem;
      cursor: pointer;

      &:hover {
        color: black; // 悬停时将文字颜色设置为黑色
      }
    }

  }

  .line {
    width: calc(100% - 20px);
    border: 0.01px solid #929292;
    margin-bottom: 40px;
  }

  .institute_list {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;


    .product-item {
      color: #333;
      width: 23%;
      height: 364px;
      margin-right: 20px;
      margin-bottom: 20px;

      img {
        width: 100%;
      }

      .time {
        font-size: 15px;
        color: #909090;
        margin-bottom: 10px;
      }

      .title {
        font-size: 1.16rem;
        font-weight: 500;
        margin-top: 10px;
        font-weight: 700;
      }

      .title2 {
        color: #afafaf;
      }
    }
  }
}
</style>